package cn.ad.enumration;

import java.util.HashMap;
import java.util.Map;

/**
 * 代理商状态
 * Created by Administrator on 2016/9/7.
 */
public enum AgencyStatus {

    AGENCY_ENABLE(1,"有效"),
    AGENCY_DISABLE(-1,"无效");

    private Integer name;
    private String value;

    private static Map<Integer,String> mappings;

    private synchronized static Map<Integer,String> getMappings(){
        if (mappings==null){
            mappings=new HashMap<>();
            for (AgencyStatus status:AgencyStatus.values()){
                mappings.put(status.name,status.value);
            }
        }
        return mappings;
    }

    AgencyStatus(Integer name, String value) {
        this.name = name;
        this.value = value;
    }

    public Integer getName() {
        return name;
    }

    public void setName(Integer name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String forValue(int value) {
        return getMappings().get(value);
    }
}
